home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / BARNET / ARMTEX / SOURCES1 / !TeX / texmf / source / armTeX / Extras / c / WhichSlot < prev   
Encoding:
Text File  |  1998-03-19  |  1.8 KB  |  59 lines

  1. /**
  2.  * WhichSlot --- Determine wimpslot required for an AIF to start
  3.  *
  4.  * say WhichSlot <AIF file>
  5.  **/
  6.  
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9.  
  10. /* The AIF header is like this */
  11. typedef struct {
  12.   /* BL decompress or BLNV 0000 if unsqueezed */
  13.   unsigned        blnv_decompress;
  14.   /* BL relocate, BL zeroinit, BL entry, SWI OS_Exit */
  15.   unsigned        initial_code[4];
  16.   unsigned        size_readonly;/* Size of RO areas */
  17.   unsigned        size_readwrite;    /* Size of RW areas */
  18.   unsigned        size_debug;    /* Size of debugging info */
  19.   unsigned        size_zeroinit;/* Size of ZI areas */
  20.   /* more follows, but we don't care */
  21. }               AIF_header;
  22.  
  23. int
  24. main(int argc, char *argv[])
  25. {
  26.   FILE           *file;
  27.   AIF_header      header;
  28.  
  29.   if (argc != 2) {
  30.     fputs("Usage: WhichSlot <AIF file>\n", stderr);
  31.     exit(EXIT_FAILURE);
  32.   }
  33.   file = fopen(argv[1], "rb");
  34.   if (file == NULL) {
  35.     fprintf(stderr, "WhichSlot: cannot read \'%s\'\n", argv[1]);
  36.     exit(EXIT_FAILURE);
  37.   }
  38.   if (1 != fread(&header, sizeof(header), 1, file)) {
  39.     fprintf(stderr, "WhichSlot: cannot read from \'%s\'\n", argv[1]);
  40.     fclose(file);
  41.     exit(EXIT_FAILURE);
  42.   }
  43.   fclose(file);
  44.  
  45.   if (header.blnv_decompress & 0xf0000000 != 0xfb000000
  46.       && header.blnv_decompress != 0xe1a00000) {
  47.     printf("Image is compressed, data may be wrong\n");
  48.   }
  49.   printf("Readonly :%6uK\n", header.size_readonly / 1024);
  50.   printf("Readwrite:%6uK\n", header.size_readwrite / 1024);
  51.   printf("Zero-init:%6uK\n", header.size_zeroinit / 1024);
  52.   printf("Debug    :%6uK\n", header.size_debug / 1024);
  53.   printf("WimpSlot :%6uK\n", (header.size_readonly
  54.                               + header.size_readwrite
  55.                               + header.size_zeroinit
  56.                               + 4096 + 1023) / 1024);
  57.   exit(EXIT_SUCCESS);
  58. }
  59.